package tech.yangzhijie.basic.thread;

import java.util.concurrent.Callable;

public class FibonacciCallable implements Callable<Integer> {

    private int n;

    public FibonacciCallable(int n) {
        this.n = n;
    }

    public FibonacciCallable() {
    }

    public int f(int x){
        return x > 2?f(x-1) + f(x-2):1;
    }

    @Override
    public Integer call() throws Exception {
        int num = 0;
        for(int i=1;i<=n;i++){
            num += f(i);
        }
        return num;
    }
}
